package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.dto.CldAssetsDepreciationDto;
import com.cleaningcloud.cld.domain.vo.CldAssetsDepreciationVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldAssetsDepreciation;
import com.cleaningcloud.cld.service.ICldAssetsDepreciationService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 资产折旧Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-07
 */
@RestController
@RequestMapping("/depreciation")
public class CldAssetsDepreciationController extends BaseController
{
    @Autowired
    private ICldAssetsDepreciationService cldAssetsDepreciationService;



    /**
     * 查询资产折旧列表统计
     */
    @RequiresPermissions("cld:depreciation:list")
    @GetMapping("/getList")
    public TableDataInfo getList(CldAssetsDepreciationDto cldAssetsDepreciation)
    {
        startPage();
        List<CldAssetsDepreciationVo> list = cldAssetsDepreciationService.getCldAssetsDepreciationList(cldAssetsDepreciation);
        return getDataTable(list);
    }

    /**
     * 查询资产折旧列表
     */
    @RequiresPermissions("cld:depreciation:list")
    @GetMapping("/list")
    public TableDataInfo list(CldAssetsDepreciationDto cldAssetsDepreciation)
    {
        startPage();
        List<CldAssetsDepreciationVo> list = cldAssetsDepreciationService.selectCldAssetsDepreciationList(cldAssetsDepreciation);
        return getDataTable(list);
    }

    /**
     * 根据项目统计折旧明细
     */
    @RequiresPermissions("cld:depreciation:list")
    @GetMapping("/getProjectDetailsList")
    public TableDataInfo getProjectDetailsList(CldAssetsDepreciationDto cldAssetsDepreciation)
    {
        startPage();
        List<CldAssetsDepreciationVo> list = cldAssetsDepreciationService.selectCldAssetsDepreciationGroupProjectList(cldAssetsDepreciation);
        return getDataTable(list);
    }



    /**
     * 获取资产折旧详细信息
     */
    @RequiresPermissions("cld:depreciation:query")
    @GetMapping(value = "/{assetsDepreciationId}")
    public AjaxResult getInfo(@PathVariable("assetsDepreciationId") Long assetsDepreciationId)
    {
        return success(cldAssetsDepreciationService.selectCldAssetsDepreciationByAssetsDepreciationId(assetsDepreciationId));
    }

    /**
     * 新增资产折旧
     */
    @RequiresPermissions("cld:depreciation:add")
    @Log(title = "资产折旧", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldAssetsDepreciation cldAssetsDepreciation)
    {
        return toAjax(cldAssetsDepreciationService.insertCldAssetsDepreciation(cldAssetsDepreciation));
    }

    /**
     * 修改资产折旧
     */
    @RequiresPermissions("cld:depreciation:edit")
    @Log(title = "资产折旧", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldAssetsDepreciation cldAssetsDepreciation)
    {
        return toAjax(cldAssetsDepreciationService.updateCldAssetsDepreciation(cldAssetsDepreciation));
    }

    /**
     * 删除资产折旧
     */
    @RequiresPermissions("cld:depreciation:remove")
    @Log(title = "资产折旧", businessType = BusinessType.DELETE)
	@DeleteMapping("/{assetsDepreciationIds}")
    public AjaxResult remove(@PathVariable Long[] assetsDepreciationIds)
    {
        return toAjax(cldAssetsDepreciationService.deleteCldAssetsDepreciationByAssetsDepreciationIds(assetsDepreciationIds));
    }

}
